/*=============================================================================
#    The element-comm is a tentative program used to test our ideas.           
#                       Copyright (C)  bgao                                    
#
#     This program is free software; you can redistribute it and/or            
#      modify it under the terms of the GNU General Public License             
#     as published by the Free Software Foundation; either version 2           
#         of the License, or (at your option) any later version.               
#
#     This program is distributed in the hope that it will be useful,          
#    but WITHOUT ANY WARRANTY; without even the implied warranty of           
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            
#             GNU General Public License for more details.                    
#
#    You should have received a copy of the GNU General Public License        
#     along with this program; if not, write to the Free Software             
#      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,             
#                       MA  02110-1301, USA.                                  
#==============================================================================
# $Id: mac_phy.h 348 2010-11-29 09:01:16Z bgao $ 
#
# $Author: bgao $ 
#
# $Revision: 348 $ 
#
# $Date: 2010-11-29 17:01:16 +0800 (星期一, 29 十一月 2010) $ 
#
# Description: 
#
=============================================================================*/
/*! @file mac_phy.h
 *  @brief This file provides the interfaces and types for the PHY.
 */
#ifndef _MAC_PHY_H_
#define _MAC_PHY_H_

#include "common.h"
#include "mem.h"

/*! the number of channels supported by 2.45GHz. */
#define NUM_OF_CHNLS_SUP  16

/*! the PHY status */
typedef enum phy_status_t_ {
    PHY_BUSY = 0x00,
    PHY_BUSY_RX = 0X01,
    PHY_BUSY_TX = 0x02,
    PHY_FORCE_TRX_OFF = 0x03,
    PHY_IDLE = 0x04,
    PHY_INVALID_PARAMETER = 0X05,
    PHY_RX_ON = 0x06,
    PHY_SUCCESS = 0x07,
    PHY_TRX_OFF = 0x08,
    PHY_TX_ON = 0x09,
    PHY_UNSUPPORTED_ATTRIBUTE = 0x0a,
    PHY_READ_ONLY = 0x0b
} phy_status_t;

/*! the PHY constant */
typedef enum phy_constant_t_ {
    aTurnaroundTime = 12,
    aMaxPHYPacketSize = 127,
} phy_constant_t;

/*! the constant indicate which CCA mode the PHY in, where CCA
 *  means clear channel assessment used to facilitate CSMA/CA.
 */
typedef enum phy_cca_mode_t_ {
    threshold = 1,
    carrier_sense = 2,
    both = 3,
} phy_cca_mode_t;

/*! the PHY information base */
typedef struct phy_pib_t_ {
    uint8 phy_current_chnl;
    uint32 phy_chnls_supported;
    /* phy_transmit_power; */
    phy_cca_mode_t phy_cca_mode;
    uint8 phy_current_page;
    uint16 phy_max_frm_duration;
    uint8 phy_shr_duration;
    uint8 phy_symbol_per_octet;
} phy_pib_t;

int8 phy_init(void);

uint8 phy_get_shr_duration(void);
uint8 phy_set_shr_duration(uint8 s);

uint8 phy_get_symbol_per_octet(void);
uint8 phy_set_symbol_per_octet(uint8 s);

#endif /* _MAC_PHY_H_ */
